home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
simula
/
books
/
books.lha
/
kirkerud
/
histofil.sim
< prev
next >
Wrap
Text File
|
1993-08-16
|
2KB
|
57 lines
begin
integer array count(5 : 200);
integer weight_group, least_weight_group, greatest_weight_group,
asterisk_number, number_of_asterisks;
real weight;
! Read the measurements one by one;
! write all measurements to the file weight.dta, and
! count how many observations there are in each weight group: ;
outtext("Please type the weights. "); outimage;
outtext("Remember to type -1 after the last one!"); outimage;
weight := inreal;
inspect new outfile("weight.dta") do
begin
open(blanks(10));
while weight ge 0 do
begin
outfix(weight,3,10); outimage;
weight_group := entier(weight);
count(weight_group) := count(weight_group) + 1;
weight := inreal;
end;
close;
end of inspect outfile;
! Find the least and greatest weight-groups containing weights: ;
least_weight_group := 5;
while count(least_weight_group) = 0
do least_weight_group := least_weight_group + 1;
greatest_weight_group := 200;
while count(greatest_weight_group) = 0
do greatest_weight_group := greatest_weight_group - 1;
! Write the histogram to file: ;
inspect new outfile("histo.res") do
begin
open(blanks(80));
outtext("Weight : Number of Students"); outimage;
for weight_group := least_weight_group step 1 until greatest_weight_group do
begin
outint(weight_group,6); outtext(" : ");
number_of_asterisks := count(weight_group);
for asterisk_number := 1 step 1 until number_of_asterisks do outchar('*');
outimage;
end weight_group-repetition;
close;
end of inspect outfile;
end;